package com.ybg.user.business.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ybg.user.business.entity.*;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper extends BaseMapper<UserInfo> {
    LoginEmployee loginEmployee(@Param("userId") int userId);
    LoginWorker loginWorker(@Param("userId") int userId);
    List<UserMenu> loginMenus(@Param("userId") int userId);
    LoginEmployee getEmployeeById(@Param("employeeId") int employeeId);
    List<String> loginRoles(@Param("userId") int userId);
    List<String> loginPermissions(@Param("userId") int userId);

    @Select("select count(*)>0 from tc_user_employee_relation where fk_user_id=#{userId} or fk_employee_id=#{employeeId}")
    boolean userBoundEmployee(@Param("userId") int userId, @Param("employeeId") int employeeId);

    @Insert("insert into tc_user_employee_relation(fk_user_id,fk_employee_id) values(#{userId},#{employeeId})")
    int bindUserEmployee(@Param("userId") int userId, @Param("employeeId") int employeeId);

    @Select("select fk_role_id from user_role_relation where fk_user_id=#{userId} and relation_status=1")
    List<Integer> userBoundRole(@Param("userId") int userId);

    /**
     * 用户绑定角色
     * @param userId
     * @return
     */
    List<IdValue> roleUserCurr(@Param("userId") int userId);
    int bindUserRole(@Param("ur") UserRole userRole);


}
